package io;
/** 读取文本 */
import java.io.*;
import java.nio.charset.StandardCharsets;

public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
        File file = new File("fos.txt");
        FileInputStream fis = new FileInputStream("fos.txt");

        byte [] date = new byte[(int)file.length()];//创建与文件等长的字节数组
        fis.read(date);//一次性读取数据到date中
        String line = new String(date, StandardCharsets.UTF_8);//将date中的字节还原为字符串
        System.out.println(line);
        fis.close();
    }
}
